﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace SC2Ranks.Web
{
    public class AchievementImage : Control
    {
        public AchievementIconInfo AchievementIcon { get; set; }

        public string ImagesFormatPath { get; set; }

        public PortraitSize Size { get; set; }

        public string CssClass { get; set; }

        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl achievementIcon = new HtmlGenericControl("div");
            var styles = Helper.GetImageCss(AchievementIcon, ImagesFormatPath, Size);

            foreach (var style in styles)
                achievementIcon.Style.Add(style.Key, style.Value);

            if (!string.IsNullOrEmpty(CssClass))
                achievementIcon.Attributes.Add("class", CssClass);

            achievementIcon.RenderControl(writer);
        }
    }
}
